$(function () {
   var ue = UE.getEditor('editor', {
       'serverUrl' : '/ueditor/upload/',
       toolbars:[[
           'undo' , //撤销
           'redo' , //重做
           'bold' , //加粗
           'italic' , //斜体
           'source' , //源代码
           'blockquote' , //引用
           'selectall' , //全选
           'insertcode' , //代码语言
           'fontfamily' , //字体
           'fontsize' , //字号
           'simpleupload' , //单图上传
           'emotion'  //表情
       ]]
   });
   window.ue = ue ;
});

$(function () {
   $('#submit-comm-btn').click(function (event) {
      event.preventDefault();

      var loginTag = $('#login-tag').html();
      if(!loginTag){
          window.location = '/signin/';
      }else {
          var content = window.ue.getContent();
          var post_id = $('#post-content').attr('data-id');
          zlajax.post({
              'url' : '/acomment/',
              'data' : {
                  'post_id' : post_id,
                  'content' : content
              },
              'success' : function (data) {
                  if(data['code'] == 200){
                      xtalert.alertSuccessToast('留言成功！');
                      setTimeout(function () {
                   window.location.reload();
               },1000)
                  }else {
                      xtalert.alertInfo(data['message']);
                  }
              },
              'fail' : function (error) {
                  xtalert.alertNetworkError('网络错误！');
              }
          })
      }
   });
});